<template>
  <div class="box1">
    <div class="title">
      <p>男女比例</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="sex">
      <div class="man">
        <img src="../../images/man.png" alt="" />
      </div>
      <div class="woman">
        <img src="../../images/woman.png" alt="" />
      </div>
    </div>
    <div class="tiaoxingtu">
      <div class="rate">
        <p>男士58%</p>
        <p>女士42%</p>
      </div>
      <div class="charts" ref="charts"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import * as echarts from 'echarts'
//获取图形图表的DOM节点
let charts = ref()
onMounted(() => {
  //初始化echarts实例
  let mycharts = echarts.init(charts.value)
  //设置配置项
  mycharts.setOption({
    //组件标题
    // title: {
    //   text: '男女比例', //主标题
    //   textStyle: {
    //     //主标题颜色
    //     color: 'skyblue',
    //   },
    //   left: '40%',
    // },
    //x|y
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      show: false,
      type: 'category',
    },
    series: [
      {
        type: 'bar',
        data: [58],
        barWidth: 20,
        itemStyle: {
          color: '#007afe',
          borderRadius: 20,
        },
        z: 100,
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        //调整女士柱条的位置
        barGap: '-100%',
        itemStyle: {
          color: '#ff4b7a',
          borderRadius: 20,
        },
      },
    ],
    grid: {
      left: 0,
      top: -26,
      right: 0,
      bottom: 0,
    },
  })
})
</script>

<style scoped lang="scss">
.box1 {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-lc.png) no-repeat center/cover;
  margin: 20px 0px;
  .title {
    margin-left: 20px;
    p {
      color: white;
      font-size: 20px;
    }
  }
  .sex {
    display: flex;
    justify-content: center;
    .man {
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 20px;
      width: 111px;
      height: 115px;
      background: url(../../images/man-bg.png) no-repeat center/cover;
    }
    .woman {
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 20px;
      width: 111px;
      height: 115px;
      background: url(../../images/woman-bg.png) no-repeat center/cover;
    }
  }
  .tiaoxingtu {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    .rate {
      display: flex;
      justify-content: space-between;
      color: white;
      width: 60%;
    }
    .charts {
      width: 60%;
      height: 80px;
    }
  }
}
</style>
